/*
可以创建不同类型的实例
*/
export { }
function Window() {
  //
}
Window.prototype.hello = function () {
  console.log('hello')
}

const createInstance = function (Constructor: any) {
  let instance: any
  return function (this: any/*←ts声明this类型的方法 不会作为arguments成员*/) {
    if (!instance) {
      // eslint-disable-next-line prefer-rest-params
      console.log('arguments:',arguments) //
      // eslint-disable-next-line prefer-rest-params
      Constructor.apply(this, arguments)
      Object.setPrototypeOf(this, Constructor.prototype)
      instance = this
    }
    return instance
  }
}
const CreateWindow: any = createInstance(Window)
const window1 = new CreateWindow()
const window2 = new CreateWindow()
window1.hello()
console.log(window1 === window2)
